package person.crud.controller;

import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import person.crud.dao.PersonDAO;
import person.model.Person;

@Controller
@RequestMapping("/edit")
public class EditController
{
    @Autowired
    PersonDAO personDAO;

    @RequestMapping("/person")
    public void editPerson(HttpServletResponse response, Person person) throws Exception
    {

	if (person != null)
	{

	    if (personDAO.update(person))
	    {
		response.getWriter().println("User updated ");
		
	    }
	    else
	    {
		response.getWriter().println("Update user error<br>hint: you must specify user id");
		
	    }	  
	}
	
    }

}
